package tools;

public class BMPUtils {
	
	public static byte[] getHeader(byte[] buf) {
		int header_end = buf[10];
		byte[] out = new byte[header_end];
		System.arraycopy(buf, 0, out, 0, header_end);
		return out;
	}
	
	public static byte[] getData(int start, byte[] buf) {
		int size = buf.length-start;
		byte[] out = new byte[size];
		System.arraycopy(buf, start, out, 0, size);
		return out;
	}
	
	public static byte[] buildImage(byte[] header, byte[] data) {
		byte[] bmp = new byte[header.length + data.length];
		System.arraycopy(header, 0, bmp, 0, header.length);
		System.arraycopy(data, 0, bmp, header.length, data.length);
		return bmp;
	}
	
	/**
	 * Affiche au format hexadécimal un tableau de byte.
	 * @param tab
	 */
	public static void showByteInfo(byte[] tab) {
		for(int i=0;i<tab.length; i++)
			System.out.println(Integer.toHexString(tab[i]));
		System.out.println("size "+tab.length);
	}
	
}
